
//
//  KeChengXueNextWoDeZiYuanView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/17.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "KeChengXueNextWoDeZiYuanView.h"

@implementation KeChengXueNextWoDeZiYuanView

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.tableList];
    [_tableList mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
}
- (UITableView *)tableList{
    if (!_tableList) {
        UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, APP_HEIGHT-84) style:UITableViewStyleGrouped];
        tableView.delegate  =self;
        tableView.dataSource = self;
        tableView.backgroundColor = [UIColor whiteColor];
        [tableView registerClass:[KeChengXueNextWoDeZiYuanViewCell class] forCellReuseIdentifier:@"KeChengXueNextWoDeZiYuanViewCell"];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _headerView = [[KeChengNextHeaderView alloc]init];
        _headerView.frame = CGRectMake(0, 0,self.frame.size.width, 131);
        tableView.tableHeaderView = _headerView;
        _tableList = tableView;
    }
    return _tableList;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 55;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    KeChengXueNextWoDeZiYuanViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KeChengXueNextWoDeZiYuanViewCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[KeChengXueNextWoDeZiYuanViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KeChengXueNextWoDeZiYuanViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击了cell");
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *mainView = [[UIView alloc]init];
    [mainView addSubview:[self topviewAdd]];
    return mainView;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *mainView = [[UIView alloc]init];
    return mainView;
}
- (UIView *)topviewAdd{
    _topView = [[KCZYTopView alloc]initWithFrame:CGRectMake(40, 0, self.frame.size.width-80, 50)];
    _topView.backgroundColor = [UIColorChange colorwithHexString:@"#F8F8F8"];
    _topView.backgroundColor = [UIColorChange colorwithHexString:@"#F8F8F8"];
    return _topView;
}
@end
